//
//  TopToolBar.swift
//  JLDiaryApp
//
//  Created by Jiang Chencheng on 2024/9/24.
//

import SwiftUI

struct TopToolBar: View {
    var body: some View {
        HStack(spacing: 10) {
            
            TopToolBarItem(value: 20, systemName: "star.fill")
            
            TopToolBarItem(value: 0, systemName: "flame.fill")
            
            TopToolBarItem(value: 10, systemName: "drop.fill")
            
        }
        .padding()
    }
}


struct TopToolBarItem: View {
    
    var value: Int = 0
    var systemName: String
    var backgroundColor: Color = .white.opacity(0.1)
    var foregroundColor: Color = .white
    
    var body: some View {
        HStack(spacing: 5) {
            Image(systemName: systemName)
            Text("\(value)")
        }
        .padding(.horizontal, 12)
        .padding(.vertical, 8)
        .background(backgroundColor)
        .foregroundColor(foregroundColor)
        .clipShape(.rect(cornerRadius: 6))
        
    }
}

#Preview {
    TopToolBar()
}
